package appconfig

import (
	"fmt"

	"github.com/spf13/viper"
)

type AppConfig struct {
	Mysql struct {
		User     string
		Password string
		Host     string
		Port     int
		Database string
	}
	Redis struct {
		Host     string
		Port     int
		Password string
		Database int
	}
	SendSms struct {
		Account  string
		Password string
	}
	Upload struct {
		AccessKey string
		SecretKey string
		Bucket    string
		Yun       string
	}
}

var Config AppConfig

func Init() {
	var err error
	viper.SetConfigFile("../appconfig/dev.yaml")
	err = viper.ReadInConfig()
	if err != nil {
		return
	}
	err = viper.Unmarshal(&Config)
	if err != nil {
		return
	}
	fmt.Println("配置成功")
}
